package com.cmcc.aregister.ui.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.model.Disease;

public class DiseaseTypeAdapter extends BaseAdapter
{
    private Context context;
    public List<Disease> list;

    public DiseaseTypeAdapter(Context context, List<Disease> list)
    {
        this.context = context;
        this.list = list;
    }

    public int getCount()
    {
        int size = list.size();
        return size;
    }

    @Override
    public boolean isEnabled(int position)
    {
        if (position >= list.size())
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public Object getItem(int position)
    {
        return position;
    }

    public long getItemId(int position)
    {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder holder;
        if (convertView != null && convertView.getTag() != null)
        {
            holder = (ViewHolder) convertView.getTag();
        }
        else
        {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(
                R.layout.a_disease, null);
            holder.name = (TextView) convertView.findViewById(R.id.name);
            convertView.setTag(holder);
        }
        holder.name.setText(list.get(position).cat_name);
        return convertView;
    }

    static class ViewHolder
    {
        TextView name;
    }
}